<template>
  <div class="BulletBoxSensor-container">
    <div class="attribute-pan">
      <div class="pan-nav">
        <div class="nav-title">{{ dataOutput.sorId + "传感器" }}</div>
        <div class="nav-info" @click="handleDetail(dataOutput)">查看详情</div>
        <div class="nav-close" @click="closeBullet"></div>
      </div>
      <div class="pan-cont">
        <div class="cont-infoMsg">
          <div class="cont-info">
            <div class="info-lable">运行状态：</div>
            <div
              :class="[
                this.RunState === '异常' ? 'Onstatus-value' : 'status-value',
              ]"
            >{{ this.RunState }}</div>
          </div>
          <div
            :class="
              this.RunState === '异常' ? 'cont-info-sensortemp' : 'cont-info'
            "
          >
            <div class="info-lable">实时温度：</div>
            <div class="info-value">{{ dataOutput.sensortemp }}</div>
          </div>
          <div class="cont-info">
            <div class="info-lable">实时电压：</div>
            <div class="info-value">{{ dataOutput.sensorvoltage }}</div>
          </div>
          <div class="cont-info">
            <div class="info-lable">最新更新时间：</div>
            <div class="info-value">{{ dataOutput.currenttime }}</div>
          </div>
          <div class="cont-info">
            <div class="info-lable">所属火区：</div>
            <div class="info-value">{{ dataOutput.address }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    dataOutput: Object
  },
  data() {
    return {
      RunState: ""
    };
  },
  watch: {
    dataOutput() {
      this.handleInitList();
    }
  },
  methods: {
    handleInitList() {
      // ifAlarm =1且ifFault=1则正常，其他异常
      if (this.dataOutput.ifAlarm === 1 && this.dataOutput.ifFault === 1) {
        this.RunState = "正常";
      } else {
        this.RunState = "异常";
      }
    },

    closeBullet() {
      this.$emit("closeBullet");
    },
    // TODO
    handleDetail(e) {
      // 传感器报警，跳转到后台：报警数据
      if (this.dataOutput.ifAlarm == 2 && this.dataOutput.ifFault != 2) {
        this.$router.push({
          path: "/alartSenor",
          query: { SensorAlartData: e }
        });
        // 传感器故障，跳转到后台：故障数据
      } else if (this.dataOutput.ifAlarm != 2 && this.dataOutput.ifFault == 2) {
        this.$router.push({
          path: "/problemSenor",
          query: { SensorAlartData: e }
        });
        // 传感器报警和故障，跳转到后台：报警数据
      } else if (this.dataOutput.ifFault == 2 && this.dataOutput.ifAlarm == 2) {
        this.$router.push({
          path: "/problemSenor",
          query: { SensorAlartData: e }
        });
      } else {
        this.$router.push({ path: "/senor", query: { SensorAlartData: e } });
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.BulletBoxSensor-container {
  user-select:none;
  width: 450px;
  height: 315px;
  background-color: rgba(8, 16, 42, 0.7);
  .attribute-pan {
    width: 100%;
    height: 100%;
    .pan-nav {
      width: 100%;
      height: 28px;
      position: relative;
      top: 25px;
      background: url("../../../../../assets/img/BullectBox/弹窗背景条.png")
        no-repeat;
      background-size: 100% 100%;
      color: #f6f9fe;
      display: flex;
      direction: row;
      .nav-title {
        width: 280px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        font-family: "AlibabaPuHuiTi-2-105-Heavy";
        font-size: 22px;
        font-weight: normal;
        font-style: italic;
        font-stretch: normal;
        letter-spacing: 0px;
        margin-left: 29px;
        margin-top: -16px;
      }
      .nav-info {
        margin-left: 10px;
        margin-top: -12px;
        font-family: "AlibabaPuHuiTi-2-105-Heavy";
        font-size: 18px;
        font-weight: normal;
        font-style: italic;
        font-stretch: normal;
        letter-spacing: 0px;
        color: #f6f9fe;
        cursor: pointer;
      }
      .nav-close {
        margin-left: 10px;
        margin-top: -16px;
        width: 33px;
        height: 33px;
        background: url("../../../../../assets/img/BullectBox/弹窗关闭.png")
          no-repeat;
        background-size: 100% 100%;
        cursor: pointer;
      }
    }
    .pan-cont {
      width: 100%;
      height: calc(100% - 28px);
      justify-content: space-around;
      .cont-infoMsg {
        width: 410px;
        height: 188px;
        margin-left: 21px;
        margin-top: 40px;
        .cont-info-sensortemp {
          margin-top: 9px;
          width: 410px;
          height: 38px;
          background: url("../../../../../assets/img/BullectBox/词条2.png")
            no-repeat;
          background-size: 100% 100%;
          display: flex;
          direction: row;
          justify-content: space-between;
          line-height: 38px;
          .info-lable {
            margin-left: 11px;
            font-family: "AlibabaPuHuiTi-2-55-Regular";
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #ffffff;
          }
          .info-value {
            margin-right: 21px;
            font-family: "AlibabaPuHuiTi-2-85-Bold";
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #ff6363;
          }
        }
        .cont-info {
          margin-top: 9px;
          width: 410px;
          height: 38px;
          background: url("../../../../../assets/img/BullectBox/词条1.png")
            no-repeat;
          background-size: 100% 100%;
          display: flex;
          direction: row;
          justify-content: space-between;
          line-height: 38px;

          .info-lable {
            margin-left: 11px;
            font-family: "AlibabaPuHuiTi-2-55-Regular";
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #ffffff;
          }
          .info-value {
            margin-right: 21px;
            font-family: "AlibabaPuHuiTi-2-85-Bold";
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #6fffed;
          }
          .status-value {
            margin-right: 21px;
            font-family: "AlibabaPuHuiTi-2-85-Bold";
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #6fffed;
          }
          .Onstatus-value {
            margin-right: 21px;
            font-family: "AlibabaPuHuiTi-2-85-Bold";
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #ff6363;
          }
        }
      }
    }
  }
}
</style>
